using UnityEngine;
using UnityEngine.InputSystem;

public class Lesson3 : MonoBehaviour
{
    Mouse mouse;
    void Start()
    {
        #region 知识点一 获取当前鼠标设备（需要引用命名空间）
        mouse = Mouse.current;
        #endregion
    }

    // Update is called once per frame
    void Update()
    {
        #region 知识点二 鼠标各键位 按下 抬起 长按
        //鼠标左键
        // Mouse.current.leftButton
        //鼠标右键
        // Mouse.current.rightButton
        //鼠标中键
        // Mouse.current.middleButton
        //鼠标向前向后键
        // Mouse.current.forwardButton
        // Mouse.current.backButton
        //按下
        if (Mouse.current.leftButton.wasPressedThisFrame)
        {
            Debug.LogFormat("鼠标左键按下");
        }
        //抬起
        if (Mouse.current.leftButton.wasReleasedThisFrame)
        {
            Debug.LogFormat("鼠标左键抬起");
        }
        //长按
        if (Mouse.current.leftButton.isPressed)
        {
            Debug.LogFormat("鼠标左键长按");
        }
        #endregion

        #region 知识点三 鼠标位置相关
        Debug.LogFormat("mouse position:{0}", Mouse.current.position.ReadValue());
        Debug.LogFormat("mouse 两帧之间偏移量:{0}", Mouse.current.delta.ReadValue());
        Debug.LogFormat("mouse 滚轮方向向量:{0}", Mouse.current.scroll.ReadValue());
        #endregion

    }
}
